<?php
//测试控制器类
class IndexController extends Controller{
    //动作方法
    public function index(){
    	//调首页的左侧分类和二级菜单
    	//1查找所有的分类数据
		$allData=M('category')->where("pid=0")->all();
		//因为顶级和二级混合，所有重新组合数组 直接压下标
		foreach ($allData as $key => $value) {
			//把二级找到压进去下标
			$allData[$key]['son'] = M('category')->where("pid={$value['cid']}")->all();
			foreach ($allData[$key]['son'] as $k => $v) {
				//找到三级的数组
				$allData[$key]['son'][$k]['sons'] = M('category')->where("pid={$v['cid']}")->all();
			}
		}
		//p($allData);
		//所有的分类
		$this->assign('allData',$allData);
		//精选频道分类
		$selection=M('category')->where("pid=0")->limit(6)->all();
		$this->assign('selection',$selection);
		//p($selection);
		//热门品牌
		$brand=M('brand')->where("is_hot=1 ")->limit(8)->all();
		$this->assign('brand',$brand);
		//p($brand);
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
        //显示视图
        $this->display();
    }
}
